﻿using System;
using System.Collections.Generic;
using System.Data;
using Luna.Data.Mappers;

namespace Luna.Data.Accounting.Mappers
{
    public class OtherOperationDataMapper : LunaEntityMapper<OtherOperationData, IOtherOperationData>
    {
        public AccountOperationDataMapper OperationMapper { get; set; }

        public string GetAllByAccountRequest { get; set; }

        protected override void LoadCoreData(IOtherOperationData P_Entity, IDataRecord P_Record)
        {
            OperationMapper.LoadFromDataRecord(P_Entity, P_Record);
        }

        public override void Save(IDbTransaction P_Transaction, IOtherOperationData P_Entity)
        {
            OperationMapper.Save(P_Transaction, P_Entity);
        }

        public override void Delete(IDbTransaction P_Transaction, Guid P_EntityKey)
        {
            OperationMapper.Delete(P_Transaction, P_EntityKey);
        }

        public IEnumerable<IOtherOperationData> GetAllByAccount(IDbTransaction P_Transaction, Guid P_AccountID)
        {
            return ExecuteGetAll(P_Transaction, GetAllByAccountRequest, c => c.AddParameter(AccountOperationDataMapper.COL_ACCOUNT, P_AccountID));
        }
    }
}
